package com.auto.producta.testcase;

import cn.hutool.http.HttpUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.rocketmq.client.exception.MQBrokerException;
import com.alibaba.rocketmq.client.exception.MQClientException;
import com.alibaba.rocketmq.remoting.exception.RemotingException;
import com.auto.base.model.MqItem;
import com.auto.base.util.CommonUtil;
import com.auto.base.util.TestUtil;
import com.auto.producta.model.UserDto;
import org.springframework.http.ResponseEntity;
import org.testng.Assert;
import org.testng.annotations.Test;

import java.text.ParseException;
import java.util.List;

public class RechargeServiceTest extends Base {

    @Test(description = "测试场景001")
    public void test001() {
        Assert.assertEquals("cccc", TestUtil.test("cccc"));
    }


    @Test(description = "测试场景002")
    public void test002() {
        Assert.assertEquals("cccc", TestUtil.test("cccc"));

    }

    @Test(description = "测试场景003")
    public void test003() {
        System.out.println(CommonUtil.buildReqMsg("product.RechargeServiceTest.normalRechargeRequestParameter"));

    }


    @Test(description = "测试场景004")
    public void test004() {
        /*查询数据库*/
        List<UserDto> userDtos = jdbcTemplate.query("select username,password from user;", UserDto.class);
        System.out.println(JSON.toJSONString(userDtos.get(0)));
        Assert.assertEquals(JSON.toJSONString(userDtos.get(0)), "{\"password\":\"12345678\",\"userName\":\"test\"}");

    }

    @Test(description = "测试场景005")
    public void test005() {
        System.out.println(params);

    }

    @Test(description = "测试场景006")
    public void test006() {
        String url = "https://www.baidu.com";
        System.out.println(HttpUtil.get(url));
    }

    @Test
    public void test007() {
        ResponseEntity<String> response = restTemplate.postForEntity("http://www.baidu.com", null, String.class);
        System.out.println(response);
    }


    @Test
    public void test008() {
       /* Object response = dubboTemplate.sendMessage(QueryService.class, "qry", QueryRequest.class, "{\n" +
                "\t\"extAttrList\":[\n" +
                "\t\t{\n" +
                "\t\t\t\"attrCode\":\"\",\n" +
                "\t\t\t\"attrValue\":\"\"\n" +
                "\t\t}\n" +
                "\t],\n" +
                "\t\"servEventId\":\"01239876\",\n" +
                "\t\"signType\":\"AES\",\n" +
                "\t\"source\":\"9999\"\n" +
                "}");
        System.out.println(response);*/
    }

    @Test
    public void mqTest() throws InterruptedException, RemotingException, MQClientException, ParseException, MQBrokerException {
        MqItem mqItem = MqItem.builder().topic("USER_NOTIFY").tags("100").message("{攀总牛逼}").build();
        mqTemplate.sendMsg(mqItem);
        mqTemplate.consumerMsg(mqItem);
    }

    public static void main(String[] args) throws MQClientException {
        MqItem mqItem = MqItem.builder().topic("USER_NOTIFY").tags("100").message("{攀总牛逼}").build();
        mqTemplate.consumerMsg(mqItem);
    }
}
